BUILD_DIR = ./build
tool_dir= /usr1/newpc/tool/bochs-2.4.6
target_dir = /usr1/newpc/build/
src_dir = $(shell pwd)
AS = nasm
ASFLAGS2 = -I ${src_dir}/boot/include/

$(BUILD_DIR)/mbr: boot/mbr.S
	$(AS) $(ASFLAGS2) $< -o $@

$(BUILD_DIR)/loader: boot/loader.S
	$(AS) $(ASFLAGS2) $< -o $@

#.PHONY:  make_biximage build_loader hd_loader  copy_image

make_biximage:
	rm -fr $(BUILD_DIR)/hd60M.img
	${tool_dir}/bximage -hd -mode="flat" -size=60 -q $(BUILD_DIR)/hd60M.img

build_loader: $(BUILD_DIR)/mbr $(BUILD_DIR)/loader

hd_loader:
	dd if=${BUILD_DIR}/mbr of=$(BUILD_DIR)/hd60M.img bs=512 count=1 conv=notrunc
	echo "write mbr to hd60M.img"
	dd if=${BUILD_DIR}/loader of=$(BUILD_DIR)/hd60M.img bs=512 count=4 seek=2 conv=notrunc
	echo "write loader to hd60M.img"
copy_image:
	cp $(BUILD_DIR)/hd60M.img ${target_dir}/



